<html xmlns:th="http://www.thymeleaf.org">
<html>
  <head>
    <base href="<%=basePath%>">
    <meta charset="UTF-8">
    <title>公告表</title>
	<meta name="pragma" content="no-cache">
	<meta name="cache-control" content="no-cache">
	<meta name="expires" content="0">
      <link href="../../../../static/easyui/themes/insdep/easyui.css" rel="stylesheet" type="text/css">
      <link href="../../../../static/easyui/themes/insdep/easyui_animation.css" rel="stylesheet" type="text/css">
      <link href="../../../../static/easyui/themes/insdep/easyui_plus.css" rel="stylesheet" type="text/css">
      <link href="../../../../static/easyui/themes/insdep/insdep_theme_default.css" rel="stylesheet" type="text/css">
      <link href="../../../../static/easyui/themes/insdep/icon.css" rel="stylesheet" type="text/css">
      <link href="../../../../static/easyui/themes/color.css" rel="stylesheet" type="text/css">
      <link href="../../../../static/ztree/zTreeStyle/zTreeStyle.css" rel="stylesheet" type="text/css" >
      <link href="../../../../static/css/common.css" rel="stylesheet" type="text/css" >
      <script type="text/javascript" src="../../../../static/jquery/jquery.min.js"></script>
      <script type="text/javascript" src="../../../../static/easyui/jquery.easyui.min.js"></script>
      <script type="text/javascript" src="../../../../static/easyui/themes/insdep/jquery.insdep-extend.min.js"></script>
      <script type="text/javascript" src="../../../../static/ztree/jquery.ztree.all.min.js"></script>
      <script type="text/javascript" src="../../../../static/easyui/easyui-lang-zh_CN.js"></script>
      <script type="text/javascript" src="../../../../static/kindeditor/kindeditor-all-min.js"></script>
  </head>
  <body >
  	<form>
   	<table id="annouceList" class="easyui-datagrid"></table>
    <div id="toolbar">
      公告标题:<input type="text" name="title" style="width:100px;height:35px;line-height:35px;" class="easyui-textbox theme-textbox-radius"/>
      部门:<input type="text" name="departmentid" style="width:100px;height:35px;line-height:35px;" class="easyui-textbox theme-textbox-radius"/>
          <input type="reset"  id="setBtn" class="easyui-linkbutton" data-options="iconCls:'icon-reload' ">
    	<a href="javascript:void(0);" onclick="return mysearch('manage/announcement/AnnouncementAction_mysearch.do')" id="searchBtn" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true">搜索</a>
    	<a href="javascript:void(0);" onclick="return add('manage/announcement/Announcement_add.do')" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true">添加</a>
    	<a href="javascript:void(0);" onclick="return edit('manage/announcement/Announcement_add.do');" id="editBtn" class="easyui-linkbutton" data-options="iconCls:'icon-edit',plain:true">修改</a>
    	<a href="javascript:void(0);" onclick="return del('Announcement_remove.do')" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true">删除</a>
    
    </div>
    </form>
    <script type="text/javascript">
    	//根据产品名称和产品价格相查询分业展示
    	function mysearch(){
    	    $("#annouceList").datagrid("load",{
    	   	 	"title":$("input[name=title]").val(),
        		"departmentid":$("input[name=departmentid]").val()
        	});
    	
    	}
    	//修改按钮事件处理函数
    	function edit(url){
    		var rows = $("#annouceList").datagrid("getChecked");
    	
    		if(!rows.length){
    			$.messager.alert("警告","请选择要修改的数据");
    			return false;
    		}
    		var announcementid = rows[0].id;
            // window.location.href=url+"?id="+announcementid;
            parent.parent.openTopWindow({
    				width:700,
    				height:500,
    				title:"修改产品信息",
    				"url":url+"?id="+announcementid,
    				close:function(){
    					$("#annouceList").datagrid("reload");
    				}

    		});
    	}
    	//添加按钮事件处理函数+
        function add(url){
            // window.location.href=url;
            parent.parent.openTopWindow({
    				width:700,
    				height:500,
    				title:"添加公告信息",
    				"url": url,
    				close:function(){
    					$("#annouceList").datagrid("reload");
    				}
    				
    			});
        }
        //删除按钮事件处理函数
        function del(url){
        	//获取到选中的一行数据
    			var rows = $("#annouceList").datagrid("getChecked");
    			
    			if(!rows.length){
    				$.messager.alert("警告","请选择要删除的数据");
    				return false;
    			}
    			$.messager.confirm("警告","数据删除后无法恢复，是否确认删除",function(b){
    				if(b){
    					var ids = new Array();
    					$.each(rows,function(index,obj){
    						ids.push(obj.id);
    					});
    					//将数组中元素使用,分割拼接为一个字符串
    					ids = ids.join(",");
    					$.post(url,
    						{
    							"ids" : ids
    						},
    						function(data){
    							if(data && data.success){
    								$.messager.alert("提示",data.msg);
    								$("#annouceList").datagrid("reload");
    								return;
    							}
    							$.messager.alert("警告",data.msg);
    					},"json");
    				}
    			});
        }
    	//加载用户数据
    	$(function(){
    		$("#annouceList").datagrid({
    			url : "/manage/announcement/findByPage.do",
    			pagination : true,
    			toolbar : "#toolbar",
    			fitColumns : true,
    			idField : "announcementid",
    			rownumbers : true,
    			//singleSelect:true,
    			columns : [
                    [
    				{field:"id",title:"文章编号",checkbox:true},
    				{field:"department",title:"通知部门",sortable:true,width:8},
    				{field:"username",title:"发表人",width:7,
                        formatter:function (value,rowData,index){
                            return  rowData.tbSystemUser.username;
                        }
                    },
    				{field:"title",title:"标题",width:10},
    				{field:"content",title:"内容",width:20},
    				{field:"updateTime",title:"更新时间",width:12},
    				{field:"status",title:"登录状态",width:7},
    	//			{field:"operation",title:"操作",formatter:function(value,rowData,index){
  		//	return "<a href='javascript:void(0)' onclick='myedit("+index+")'>修改</a>"+"&nbsp;&nbsp;"+
  		//	" <a href='javascript:void(0)' onclick='editproduct("+index+")'>删除</a>"
       //}},	
    			]
                ],
    			loadFilter:function(data){
    				//data是服务器返回的数据,将服务器端返回的数据转换为datagrid需要的格式
    				return {"total":data.data.totalRows,"rows":data.data.result};
    			}
    		
    		});
    	});
    	
    		//function modify(index){
				//$("#annouceList").datagrid("selectRow",index)
				//var row=$("#annouceList").datagrid("getSelected")
				//var id=row.taskid;
			//	parent.openTopWindow(
				//{
				//	width:500,
				//	height:700,
				//	title:"修改",
				//	url:"manage/task/TaskAction_modify.action"+"?taskVo.taskid="+id,
				//	close:function(){
				//		$("#taskList").datagrid("reload")
				//	}
				//}
				//)
			//}
  
    </script>
  </body>
</html>
